Skip to content

Instantly share code, notes, and snippets.

[<Erase>]
type IProp<'comp when 'comp : not struct> = | Prop of string * obj
with
static member inline Create (value: string * obj) = Prop value
static member inline Build(props: IProp<'comp> seq) = props |> unbox<(string * obj) seq> |> createObj |> unbox<'comp>
let inline (!<) x = IProp.Build x
module Interop =
let inline mkProperty<'Component when 'Component : not struct> (key:string) (value:obj) : IProp<'Component> =
@Horusiath
Horusiath / Prolog.fs
Last active May 17, 2024 15:12
Yata move algorithm
namespace Demos
open System
type ReplicaId = String
[<RequireQualifiedAccess>]
module Array =
@securitytube
securitytube / DllMainThread.c
Created November 1, 2014 11:10
Launch Shellcode as a Thread via DllMain rather than a new process
// Dll Hijacking via Thread Creation
// Author - Vivek Ramachandran
// Learn Pentesting Online -- http://PentesterAcademy.com/topics and http://SecurityTube-Training.com
// Free Infosec Videos -- http://SecurityTube.net
#include <windows.h>
#define SHELLCODELEN 2048
@Horusiath
Horusiath / HashRings.fs
Last active May 17, 2024 15:12
Hash rings implementations in F#
module Demo.HashRings
open System
open System.Collections.Generic
/// Range is a tuple describing (s,e] - where `s` is start
/// (exclusive) index, while `e` is end (inclusive) index.
type Range = ValueTuple<int,int>
[<RequireQualifiedAccess>]
@sippsolutions
sippsolutions / bumble-chatlog-export.js
Created December 6, 2022 15:38
Bumble Chatlog Export (paste in Browser Console while being on an individual Chat Page)
(function () {
function l(u, i) {
var d = document;
if (!d.getElementById(i)) {
var s = d.createElement('script');
s.src = u;
s.id = i;
d.body.appendChild(s);
}
}
@r-malon
r-malon / monokai.md
Created February 27, 2019 19:15
Monokai colors in RGB and HEX format, taken from Sublime Text 3

Monokai Colors in RGB and HEX format


  • Background: (46, 46, 46); #2e2e2e
  • Comments: (121, 121, 121); #797979
  • White: (214, 214, 214); #d6d6d6
  • Yellow: (229, 181, 103); #e5b567
  • Green: (180, 210, 115); #b4d273
  • Orange: (232, 125, 62); #e87d3e
  • Purple: (158, 134, 200); #9e86c8
@Horusiath
Horusiath / Ramp.fs
Last active May 17, 2024 15:11
RAMP Hybrid transaction protocol implementation using Akka.NET in F#
module Demo.Ramp
open System
open Akka.Actor
open Akkling
/// A Lamport clock timestamp used as transaction identifier - sequence number with unique node identifier.
/// Original paper implementation uses combination of hybrid logical clock with node id encoded together into uint64.
type TxnId = DateTime * int
@nymous
nymous / README.md
Last active May 17, 2024 15:10
Logging setup for FastAPI, Uvicorn and Structlog (with Datadog integration)

Logging setup for FastAPI

This logging setup configures Structlog to output pretty logs in development, and JSON log lines in production.

Then, you can use Structlog loggers or standard logging loggers, and they both will be processed by the Structlog pipeline (see the hello() endpoint for reference). That way any log generated by your dependencies will also be processed and enriched, even if they know nothing about Structlog!

Requests are assigned a correlation ID with the asgi-correlation-id middleware (either captured from incoming request or generated on the fly). All logs are linked to the correlation ID, and to the Datadog trace/span if instrumented. This data "global to the request" is stored in context vars, and automatically added to all logs produced during the request thanks to Structlog. You can add to these "global local variables" at any point in an endpoint with `structlog.contextvars.bind_contextvars(custom

@Horusiath
Horusiath / Fiber.fs
Last active May 17, 2024 15:09
Custom fibers implementation in F#
/// MIT License
///
/// Copyright (c) 2024 Bartosz Sypytkowski
///
/// Permission is hereby granted, free of charge, to any person obtaining a copy
/// of this software and associated documentation files (the "Software"), to deal
/// in the Software without restriction, including without limitation the rights
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
/// copies of the Software, and to permit persons to whom the Software is
/// furnished to do so, subject to the following conditions:
@eulerfx
eulerfx / EventSourcingMonoids.fs
Last active May 17, 2024 15:09
F# event-sourcing with monoids
type Monoid<'a> = {
unit : 'a
op : 'a -> 'a -> 'a
}
let endo<'a> =
{ unit = id
op = fun (f:'a -> 'a) (g:'a -> 'a) -> f << g }